import { RegisterComponent } from "@feng3d/ecs";
import { SpotLight } from "../../thirdparty/three/imports";
import { Light3D } from "./Light3D";
import { SpotLightShadow3D } from "./SpotLightShadow3D";

declare module "@feng3d/ecs"
{
    interface ComponentMap { SpotLight3D: SpotLight3D; }
}

/**
 * 3D点光源，包装`three`中`PointLight`
 */
@RegisterComponent({ name: 'SpotLight3D' })
export class SpotLight3D extends Light3D
{
    _light: SpotLight = new SpotLight();

    shadow: SpotLightShadow3D = new SpotLightShadow3D(this._light.shadow);

    get distance()
    {
        return this._light.distance;
    }
    set distance(v)
    {
        this._light.distance = v;
    }

    get angle()
    {
        return this._light.angle;
    }
    set angle(v)
    {
        this._light.angle = v;
    }

    get penumbra()
    {
        return this._light.penumbra;
    }
    set penumbra(v)
    {
        this._light.penumbra = v;
    }

    get decay()
    {
        return this._light.decay;
    }
    set decay(v)
    {
        this._light.decay = v;
    }

    destroy(): void
    {
        this.shadow = null;

        super.destroy();
    }
}
